package tau.pimpmyfreedb.dal;

import java.sql.SQLException;
import java.util.ArrayList;

import tau.pimpmyfreedb.common.types.PagedSearchResult;

/**
 * The DAL layer interface. Intended to be user by the BL layer (PimpMaster).
 * Each thread of the PimpMaster holds a single IDalController and work with it
 * in a synchronous manner.
 */
public interface IDalController {

    // status
    void connect(String url, String username, String password)
	    throws SQLException;

    void disconnect() throws SQLException;

    boolean isConnected();

    // bulk get / search
    PagedSearchResult<IDataItem[]> getData(DataFilter filter) throws SQLException;
    
    // submit
    DalResponse insertData(IDataItem[] data) throws SQLException;
    DalResponse updateData(IDataItem[] data) throws SQLException;
    DalResponse deleteData(IDataItem[] data) throws SQLException;
    
    DalResponse insertRelations(ArrayList<DataItemRelation> relations)
	    throws SQLException;
    DalResponse deleteRelations(ArrayList<DataItemRelation> relations)
	    throws SQLException;
}
